(function(window, $){
	var remoteBasePath = 'http://newmbs.bj.unicom.local:9085/attach/';
	var _baseHtmlPath = remoteBasePath+'/static/html/folder';
	var _baseRemotePath = remoteBasePath+'/remoteApi/Folder';
	var _dataGridId = "dataGrid";
	var userId1;
	fileweb = {};
	
	fileweb = {
		downloadToWeb:function(userId,fileArray){	
			//fileArray="[{'fileName':'test.txt','fileId':'c11ecad5-8031-410b-af48-2ef6dae82a25','systemId':'MBS系统','model_id':'公文管理','bo_def_id':' 00','bo_instance_id':'00'},{'fileName':'test.txt','fileId':'38ff4367-1722-4a16-be43-41667092bd29','systemId':'MBS系统','model_id':'公文管理','bo_def_id':' 00','bo_instance_id':'00'}]";
			var _parentContent = $('<div></div>');
			_parentContent.load(_baseRemotePath+'/tomove?userId='+userId);
			BootstrapUDialog.show({
	            title: '下载附件至网盘',
	            message: _parentContent,
	            onshown:function(){	//可以在这对打开的页面进行标签的初始化
	            	folder.Dialog.initAdd(_parentContent);
	            },
	            buttons: [{
	                label: '保存',
	                action: function(dialogRef){
	                	var endField = $('#endField').val();
	                	if(endField != "" && endField != null){
	                		$.ajax({
	            				type : "post",
	            				url:_baseRemotePath+'/toDownLoad',
	            				data:{userId:userId,fileArray:JSON.stringify(fileArray),endField:endField}
	            			})
	            			.done(function(date) {
	            				alert("下载成功");
	            				dialogRef.close();
	            			})
	            			.fail(function() {
	            				alert("下载失败！");//后台报错的话就提示执行这个 
	            			});
	                		
	                	}else{
	                		alert("请选择文件夹");
	                	}
	                }
	            }, {
	                label: '取消',
	                action: function(dialogRef){
	                    dialogRef.close();
	                }
	            }],
	            cssClass:'bsubmit',
	            draggable: true
	        });
		},
		uploadFromWeb:function(userId,callBackFunc){	//从网盘中选择文件上传
			
	 	var _parentContent = $('<div></div>');
	 	//var url=_baseRemotePath+"/tomoveUpload?userId="+userId;
	 	var url="http://newmbs.bj.unicom.local:9085/attach/remoteApi/Folder/tomoveUpload?userId="+userId;
	 	
			_parentContent.load(url)

			
			//_parentContent.load('http://newmbs.bj.unicom.local:9085/commons-attachment/treedemo.jsp');
			//_parentContent.load("http://newmbs.bj.unicom.local:9085/attach");
			BootstrapUDialog.show({
	            title: '选择网盘文件',
	            message: _parentContent,
	            onshown:function(){
	            	folder.Dialog.initAdd(_parentContent);
	            },
	            buttons: [{
	                label: '保存',
	                action: function(dialogRef){	//获取所有选中的文件id
	                	var ids=asd();
	                	// 回调函数
	                	if(callBackFunc){
	                		callBackFunc(ids);
	                		// 关闭窗口
	                		dialogRef.close();
	                	}
	                }
	            }, {
	                label: '取消',
	                action: function(dialogRef){
	                  dialogRef.close();
	                }
	            }],
	            cssClass:'bsubmit',
	            draggable: true
	        });
			
		},
		initValidate:function(){
				$("#form").validationEngine("attach",{
					relative: true,
			        scroll: false, 
			        validationEventTrigger:"keyup blur",
			        ValidateNoneVisibleFields: true
				});
			}
	};
	
	fileweb.Grid = {
			getGrid:function(){
				return $('#' + _dataGridId);
			},
			getCheckedData:function(){
				return fileweb.Grid.getGrid().datagrid('getChecked');
			}
	};
	
	window.fileweb = fileweb;
	
	$(function(){
	});
})(window, jQuery);